#ifndef MYLABEL_H
#define MYLABEL_H
#include <QLabel>
#include <QPushButton>
#include "UIEditor/uilib.h"

class MyLabel:public QLabel
{
    Q_OBJECT
public:
    MyLabel(QWidget* parent = nullptr);
    ~MyLabel();
    bool IsSelected();
enum {
    TOPLEFT = 11,
    TOP = 12,
    TOPRIGHT = 13,
    LEFT = 21,
    CENTER = 22,
    RIGHT = 23,
    BUTTOMLEFT = 31,
    BUTTOM = 32,
    BUTTOMRIGHT = 33
};

#define FRAMESHAPE 10
public:
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    int CalCursorCol(QPoint pt);    //计算鼠标X的位置
    int CalCursorPos(QPoint pt, int colPos);    //计算鼠标的位置
    void setCursorShape(int CalPos);    //设置鼠标对应位置的形状

    void Refresh(LabelInfo* labelInfo = nullptr);
    void SetSelectedDisabled(bool disable);

    LabelInfo* info = nullptr;
    int id = 0;//在父窗口的渲染顺序排行，越小就越早渲染
protected:
    void paintEvent(QPaintEvent *e);
private:
    int     m_iCalCursorPos;
    bool    m_bLeftPress;
    QRect   m_rtPreGeometry;
    QPoint  m_ptViewMousePos;
    bool selected = false;//被选中
    bool selectDisabled = false;
};

#endif // MYLABEL_H
